package com.futvan.z.erp.zstorehouse;

import com.futvan.z.framework.core.z;
import org.springframework.stereotype.Service;
import com.futvan.z.framework.core.SuperService;

import java.util.List;

@Service
public class ZstorehouseService extends SuperService {

    /**
     * 根据区域id获取信息
     *
     * @param areaid
     * @return
     */
    public z_storehouse_area getStoreArea(String areaid) {
        z_storehouse_area area = sqlSession.selectOne("z_storehouse_area_select_sql", "select * from z_storehouse_area where areaid = '" + areaid + "'");
        return area;
    }

    /**
     * 获取默认发货仓库
     *
     * @return
     */
    public String getString() {
        List<z_storehouse> area = sqlSession.selectList("z_storehouse_select_sql", "select * from z_storehouse order by 'desc'");
        if (z.isNotNull(area) && area.size() > 0) {
            return area.get(0).getZid();
        } else {
            return "";
        }
    }

    /**
     * 判断是否有仓库
     * @param store
     * @return
     */
    public String checkStore(String store) {
        z_storehouse list = sqlSession.selectOne("z_storehouse_select_sql", "select * from z_storehouse where name = '" + store + "'");
        if (z.isNotNull(list)) {
            return list.getZid();
        }
        return "";
    }
}
